import React from 'react'
import { Table, Pagination } from 'antd'
import '../batchRecord/search.css'
import styles from '@/components/batchRecord/table.scss'
import util from '@/utils'

const { Column } = Table

const WhiteListTable = (props) => {

  const { pageNum, pageSize, total, loading, data, onDelete, onChangePagination } = props

  return (
    <div>
      <Table 
        dataSource={data}
        loading={loading}
        pagination={false}
        rowKey={({id}, i) => i}
      >
        <Column title="号码" dataIndex="phone" align="center"/>
        <Column title="添加时间" dataIndex="createTime" render={(value) => 
         util.transformTimeStampToString(value)
        } align="center"/>
        <Column title="操作" render={(props, value) => (
          <span>
            <a href="javascript:;" onClick={onDelete.bind(props,value)}>删除</a>
          </span>
        )} align="center" />
      </Table>
      {!!total && <div className={styles["pagination-container"]}>
        <Pagination 
          className={styles["pagination"]} 
          showQuickJumper showTotal={(total, range) => `共${total}条`} 
          pageSize={pageSize} 
          current={pageNum} 
          total={total} 
          onChange={onChangePagination} 
        />
      </div>
      }
    </div>
  )
}

export default WhiteListTable